package com.ruicar.afs.cloud.basic.proceeds.pay.service.impl;

import com.ruicar.afs.cloud.basic.proceeds.pay.entity.BasicPaymentPool;
import com.ruicar.afs.cloud.common.core.security.util.SecurityUtils;
import com.ruicar.afs.cloud.common.modules.contract.enums.OperateResultEnum;
import com.ruicar.afs.cloud.common.modules.contract.enums.OperateTypeEnum;
import com.ruicar.afs.cloud.common.util.EmptyUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.basic.proceeds.pay.service.BasicPaymentOperateLogService;
import com.ruicar.afs.cloud.basic.proceeds.pay.entity.BasicPaymentOperateLog;
import com.ruicar.afs.cloud.basic.proceeds.pay.mapper.BasicPaymentOperateLogMapper;

import java.util.Calendar;

/**
 * @author: Lee
 * @date 2020-05-30 04:35:07 
 * @description 
 */
@Service
public class BasicPaymentOperateLogServiceImpl extends ServiceImpl<BasicPaymentOperateLogMapper, BasicPaymentOperateLog> implements BasicPaymentOperateLogService {

    @Override
    public void addOperateLog(BasicPaymentPool pool, OperateTypeEnum operateType, OperateResultEnum operateResult) {
        BasicPaymentOperateLog paymentOperateLog = new BasicPaymentOperateLog();
        paymentOperateLog.setPoolId(pool.getId());
        paymentOperateLog.setOperateType(operateType);
        paymentOperateLog.setOperateTime(Calendar.getInstance().getTime());
        paymentOperateLog.setOperateResult(operateResult);
        paymentOperateLog.setOperateUser(EmptyUtils.isNotEmpty(SecurityUtils.getUser())?SecurityUtils.getUser().getUsername():"system");
        paymentOperateLog.setRemarks(null);
        this.save(paymentOperateLog);
    }
}
